<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
set_html('title','登录商户');
if($_RQ['op']=='get'){
	$return['set']=$this->plugin_setting('setting');
	$return['set']['loginlogo']=tomedia($return['set']['loginlogo']);
	$return['set']['loginbg']=tomedia($return['set']['loginbg']);
	if($_SESSION['os']=='windows'){
		$return['session_id']=session_id();
	}
	if($_SESSION['uid']){
		exi('','error','jy_douyintui/merch.index/');
	}
	$_SESSION['logout_forward']='jy_douyintui/merchlogin/';
	$_SESSION['forward_url']='jy_douyintui/merch.index/'; 
	$return['forward_url']=base64_encode($_SESSION['forward_url']);
	$return['info']=array();
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	if(!$post['password'] || !$post['mobile']){
		exi('请填写手机号和密码','error');
	}
	$user=$this->pdo_get('merch',array('uniacid'=>$_SESSION['uniacid'],'mobile'=>$post['mobile']));
	if(!$user || $post['password']!=base64_decode($user['upass'])){
		exi('用户名或密码错误','error');
	}
	if(!$user['mid']){
		exi('该商户没有绑定用户/管理员！','error');
	}
	$_SESSION['uid']=$user['mid'];
	$_SESSION['merchid']=$user['id'];
	$_SESSION['member']['username']=$user['mobile'];
	//绝对地址，会刷新页面
	$url=custom_url('jy_douyintui/merch.index/',true);
	exi('登陆成功!','',$url);
	
}